<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div></div>
  <script>
    const div = document.querySelector('div')
   
    setInterval(function(){
      const now = +new Date()
      const last = +new Date('2024-01-01 00:00:00')
      const count = last - now
      const day = Math.floor(count / 1000 / 60 / 60 / 24)
      const hour = Math.floor(count / 1000 / 60 / 60 % 24)
      const seconds = Math.floor(count / 1000 % 60)
      const minutes = Math.floor(count / 1000 / 60 % 60)
      div.innerHTML = `距离2024年还有${day}天${hour}小时${minutes}分钟${seconds}秒`
      
    },1000)
  </script>
</body>
</html>